﻿@using Ids.Web.Listing
@using System.Collections
@using System.Collections.Generic
@using Novagoal.Website.WebApp.Helpers
@using System.Text
@using Novagoal.Website.Models

@model SubmitResults

@{
    var warnings =  new List<string>();
    var model = ViewData.Model as ModelErrors;
    if (model != null && model.HasWarnings())
    {
        warnings.AddRange(model.Warnings);
    }

    var tempWarning = TempData.GetMessage(MessageType.Warning);
    if (!string.IsNullOrEmpty(tempWarning))
    {
        warnings.Add(tempWarning);
    }

    MvcHtmlString HtmlDisplay = null;
    if (warnings.Count > 0)
    {
        var warningHtml = new StringBuilder();
        if (warnings.Count == 1)
        {
            warningHtml.AppendFormat("<b class=\"orange\">WARNING:</b> {0}", warnings.First());
        }
        else
        {
            warningHtml.Append("<b class=\"orange\">Check the following Warnings:</b><br/>");
            warningHtml.Append("<ul>");
            foreach (var item in warnings)
            {
                warningHtml.AppendFormat("<li>{0}</li>", item);
            }
            warningHtml.Append("</ul>");
            
        }
        HtmlDisplay = MvcHtmlString.Create(warningHtml.ToString());
    }
}

@if (warnings.Count > 0)
{
<div class="form-messages-panel ui-state-warning ui-corner-all"> 
    <span class="message-icon ui-icon ui-icon-notice"></span>
    @HtmlDisplay
</div>
}